import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * La clase BalaExtra provee de Objetos que pueden aumentar el numero de balas del jugador
 * 
 * @author Jose Luis Sandoval Quintero
 * @version 5-Junio-2012
 */
public class BalaExtra extends Actor
{
    /**
     * Act - do whatever the BalasExtra wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        move( -1 );
        if( super.getX() == 0 || esSpiderman() )
        {
            if( esSpiderman() )
                ((SpidermanWorld)getWorld()).cambiaNbalas( 15 );
            getWorld().removeObject( this );
        }
    }   
    /**
     * Regresa true en caso de que halla intersectado con spaiderman
     * de lo contrario regresa false.
     */
    public boolean esSpiderman()
    {
        boolean res = false;
        Actor s = getOneIntersectingObject( Spiderman.class );
        if( s != null )
            res = true;
        return res;
    }
}
